import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import axios from "axios";
import $ from "jquery";
import Navigation from "vue-navigation";
// import history from "connect-history-api-fallback";
// import express from "express";
import layer from "./assets/js/common/layer";
// import layer from "vue-layer-mobile";
// import appKeyWords from "./assets/js/app_rizhi/appKeywords";
import localStorage from "./assets/js/app_quanjiyin/localStorage";
import API from "./assets/js/app_quanjiyin/api";
// import md5 from "js-md5";
import "./registerServiceWorker";
// import "./assets/js/app_quanjiyin/vconsole";
import "./assets/js/common/flexible";
import "./assets/js/common/fastclick.min";
// import "vue-layer-mobile/need/layer.css";
import "./assets/js/common/need/layer.css";
import "./assets/css/reset.css";
import "./assets/css/common-a.scss";
import "./assets/css/animate.css";

Vue.use(Navigation, { router, store });
Vue.config.productionTip = false;
Vue.prototype.$axios = axios;
Vue.prototype.$API = API;
// Vue.prototype.$md5 = md5;
Vue.prototype.$layer = layer;
// Vue.use("/", history());
// Vue.prototype.$appKeyWords = appKeyWords;
Vue.prototype.$localStorage = localStorage;
// axios.defaults.baseURL =
//   process.env.NODE_ENV === "production" ? "https://hn2.api.okayapi.com" : "/";
new Vue({
  router,
  store,
  axios,
  API,
  // express,
  $,
  // md5,
  layer,
  localStorage,
  // appKeyWords,
  render: h => h(App),
  mounted() {
    const s = document.createElement("script");
    s.type = "text/javascript";
    s.src = "https://at.alicdn.com/t/font_989682_taca7p9h2t.js";
    document.body.appendChild(s);
    // window.addEventListener(
    //   "popstate",
    //   function() {
    //     store.commit("setTransition", "slide-back");
    //   },
    //   false
    // );
    // router.beforeEach((to, from, next) => {
    //   // console.log(to.name);
    //   const nextRoute = [
    //     "shaoma",
    //     "sjlists",
    //     "sjforma",
    //     "sjformb",
    //     "sjformc",
    //     "sjformd",
    //     "sjSubmit",
    //     "sjView"
    //   ];
    //   let isLogin = store.state.isLogin; // 判断是否登录
    //   // 未登录状态；当路由到 nextRoute 指定页时，跳转至 UserLogIn
    //   if (nextRoute.indexOf(to.name) >= 0) {
    //     if (isLogin === 0) {
    //       router.push({
    //         path: "/logPage",
    //         query: { redirect: to.fullPath }
    //       });
    //     }
    //   }
    //   // 已登录状态；当路由到 UserLogIn 时，跳转至 Home
    //   if (to.name === "logPage") {
    //     if (isLogin === 1) {
    //       next("/sjlists");
    //       return;
    //     }
    //   }
    //   next(); // 必须使用 next ,执行效果依赖 next 方法的调用参数
    // });
  }
}).$mount("#app");
